#include "Ender.h"
#include "Evas.h"
#include "Ecore_Evas.h"
#include "efl_ender_evas.h"

#if 0
static void _cb_resize(Ecore_Evas *ee)
{
	Evas *evas;
	Evas_Object *o;
	int width;
	int height;

	ecore_evas_geometry_get(ee, NULL, NULL, &width, &height);
	evas = ecore_evas_get(ee);
	/* resize the svg object */
	o = evas_object_name_find(evas, "svg");
	evas_object_resize(o, width, height);
	/* TODO put the controls on the same position */
}
#endif

int main(void)
{
	Ecore_Evas *nee;
	Evas *nevas;
	Evas_Object *no;
	Ender_Element *evas;
	Ender_Element *o  = NULL;
	Ender_Descriptor *d;

	efl_ender_evas_init();
	ecore_evas_init();

	/* create an ecore window */
	nee = ecore_evas_new(NULL, 0, 0, 0, 0, NULL);
	if (!nee) return -1;
	nevas = ecore_evas_get(nee);
	if (!nevas) return -1;

	/* wrap the evas canvas from its native form */
	d = ender_namespace_descriptor_find(efl_ender_evas_namespace_get(), "evas");
	//ecore_evas_callback_resize_set(ee, _cb_resize);
	evas = ender_descriptor_element_new_from_data(d, nevas);
	/* add a new rectangle */
	ender_element_function_call(evas, EFL_ENDER_EVAS_RECTANGLE_ADD, &o, NULL);
	ender_element_property_value_set(o, EFL_ENDER_EVAS_OBJECT_WIDTH, 320, EFL_ENDER_EVAS_OBJECT_HEIGHT, 240, EFL_ENDER_EVAS_OBJECT_VISIBLE, EINA_TRUE, NULL);

	ecore_evas_resize(nee, 320, 240);
	ecore_evas_show(nee);
	ecore_main_loop_begin();
	ecore_evas_shutdown();
	return 0;
}
